package team.southcat.wsyygh.common.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import team.southcat.wsyygh.common.result.Result;
import team.southcat.wsyygh.common.service.CategoryService;
import team.southcat.wsyygh.model.pojo.common.Category;

import java.util.List;

@Api(tags = "分类管理接口")
@RestController
@RequestMapping("/admin/common/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @ApiOperation("查询所有ParentId下的category")
    @GetMapping("/getChildByParentId/{id}")
    public Result getChildByParentId(@PathVariable int id){
        List<Category> categories = categoryService.getChildByParentId(id);
        return Result.ok(categories);
    }
    @ApiOperation("查询所有医院等级")
    @GetMapping("/getAllHospitalType")
    public Result getAllHospitalType(){
        List<Category> categories = categoryService.getAllHospitalType();
        return Result.ok(categories);
    }

    @ApiOperation("查询所有证件类型")
    @GetMapping("/getAllCertificateType")
    public Result getAllCertificateType(){
        List<Category> categories = categoryService.getAllCertificateType();
        return Result.ok(categories);
    }

    @ApiOperation("查询所有学历")
    @GetMapping("/getAllEducationType")
    public Result getAllEducationType(){
        List<Category> categories = categoryService.getAllEducationType();
        return Result.ok(categories);
    }

    @ApiOperation("查询所有民族")
    @GetMapping("/getAllNationalityType")
    public Result getAllNationalityType(){
        List<Category> categories = categoryService.getAllNationalityType();
        return Result.ok(categories);
    }

    @ApiOperation("根據id查询")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable int id){
        Category category = categoryService.getById(id);
        return Result.ok(category);
    }


}
